//
//  SKSTableViewCell.m
//  laziz_Consumer
//
//  Created by XMac on 16/12/16.
//  Copyright © 2016年 XBN. All rights reserved.
//

#import "SKSTableViewCell.h"

@interface SKSTableViewCell ()

@property (strong, nonatomic) IBOutlet UIImageView *titleImageView;

@property (strong, nonatomic) IBOutlet UILabel *titleLabel;


@end


@implementation SKSTableViewCell


- (void)awakeFromNib {
    [super awakeFromNib];
    self.expandable = YES;
    self.expanded = NO;
    
    self.backgroundColor = [UIColor clearColor];
}

- (UIView *)expandableView
{
    UIImage *image = [UIImage imageNamed:@"comment_av_view_down"];
    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
    CGRect frame = CGRectMake(0.0, 0.0, image.size.width, image.size.height);
    button.frame = frame;
    [button setBackgroundImage:image forState:UIControlStateNormal];
    
    return button;
}

-(void)changeTitleImage:(UIImage *)xImage{
    _titleImageView.image = xImage;
}

-(void)changeTitle:(NSString *)xTitle{
    _titleLabel.text = xTitle;
}



- (void)setExpandable:(BOOL)isExpandable
{
//    if (isExpandable)
//        [self setAccessoryView:[self expandableView]];
//    
    _expandable = isExpandable;
    self.arrowImageView.hidden = !isExpandable;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
    [super setSelected:selected animated:animated];
}

- (void)accessoryViewAnimation
{
    [UIView animateWithDuration:0.2 animations:^{
        if (self.isExpanded) {
            self.arrowImageView.transform = CGAffineTransformMakeRotation(M_PI);

//            self.accessoryView.transform = CGAffineTransformMakeRotation(M_PI);
            
        } else {
            self.arrowImageView.transform = CGAffineTransformMakeRotation(0);

//            self.accessoryView.transform = CGAffineTransformMakeRotation(0);
        }
    } completion:nil];
}

@end
